import request from '@/utils/request'

export function login(data, appName) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-login/in',
    method: 'post',
    data,
    params: { appName }
  })
}

export function loginWithCheckCode(data, appName) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-login/loginWithCheckCode',
    method: 'post',
    data,
    params: { appName }
  })
}

export function getInfo(appName) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-login/userInfo',
    method: 'get',
    params: { appName }
  })
}

export function logout() {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-login/out',
    method: 'get'
  })
}

export function getAdminUserList(data) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-user/list',
    method: 'post',
    data
  })
}

// 获取验证码
export function getCheckCode() {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/checkCode/get',
    method: 'get'
  })
}

// 修改用户密码
export function changePassword(data) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/app-login/changePassword',
    method: 'post',
    data
  })
}

// 获取app的数据字典
export function getDataDicByApp(appName) {
  return request({
    baseURL: process.env.VUE_APP_UNIONAUTH_API,
    url: '/data-dic/getDataDicByApp',
    method: 'get',
    params: { appName }
  })
}
